<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Hello</title>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
</head>
<body>
<h3>文件上传</h3>
<form action="{:url('home/home/upload')}" class="demo" method="post" enctype="multipart/form-data">
    <input type="file" name="file">
    <br>
    <br>
    <br>
    <button type="button">上传</button>
</form>
</body>
</html>
<script>
    // 文件上传js
    $("button").click(function(){
        // 判断不允许为空
        if($("input[name=file]").val() == ""){
            alert("亲，不允许为空哦！");
            return false;
        }
        $(".demo").submit();
    })
</script>